---
title: "Replication material for: 'Covid-19 Conspiracy Belief and Conceptions of Democracy'"
author: " "
date: "2024-09-26 (Update: 2024-11-28)"
output: 
  html_document:
    theme: flatly
    toc: yes
    toc_float:
      collapsed: no
      smooth_scroll: no
    number_sections: no
    code_folding: show
---

```{r setup, include=F, echo=F, message=F, warning=F}
knitr::opts_chunk$set(echo = TRUE)

# rm(list=ls())

library(haven)
library(car)
library(survey)
library(psych)
library(corrplot)
library(weights)
library(wdm)

library(MASS)
library(brant)
library(AER)

library(tidyverse)

library(knitr)
library(kableExtra)
library(modelsummary)

options(scipen=999)



#### Define functions ####

##### functions for output and model fit svyglm #####

## function for LRT equivalent for quasibinomial glm (F-Test)
# the function outputs the result of an F-Test on a quasibinomial glm model
# it first calculates the null model, 
# then compares full model to null model using anova
# we need to input the dv, and the full_model
# Note that the other parameters (weight, data) are already set to the dataset used in this script
# Note that you need to input the DV as a string: "my_var"
modelfit_fun_glm <- function(dv, m_full) {
  null_formula <- as.formula(paste(dv, "~ 1")) # outputs: dv ~ 1
  m_null <- glm(null_formula,
                     family = quasibinomial(link = "logit"),
                     weights = persgew, # correct weight already selected
                     data = tm) # automatically set to tm
  anova(m_null, m_full, test = "F")
}


## formula that computes a deviance-based quasi-McFadden
# it first calculates the null model, then McFaddens
# it works with quasibinomial b/c it's deviance-based; not LogLik
# the formula for McFadden's: 1 - (deviance_full / deviance_null)
# inputs: dv = the DV, df = the dataframe, m_full = full model
# Note that you need to input the DV as a string: "my_var"
quasi_mcfadden <- function(dv, df_w, m_full) {
  # null model
  null_formula <- as.formula(paste(dv, "~ 1")) # outputs: dv ~ 1
  m_null <- svyglm(null_formula, # is: dv ~ 1
                   family = quasibinomial(link="logit"),
                   design = df_w) 
  # Compute McFadden's 
  dev_full <- deviance(m_full) # deviance full model
  dev_null <- deviance(m_null) # based on null model
  mcfadden <- 1 - (dev_full / dev_null) # quasi Mc Fadden 
  return(round(mcfadden,3))
}

## Function for histogram with normal distribution (unweighted data)
hist_norm <- function(var_name) {
  var_name_string <- deparse(substitute(var_name)) # extract var_name as string
  hist(var_name, 
       freq = F, breaks = 8,
       main = paste0("Histogram of ", var_name_string))
  curve(dnorm(x, # add normal curve
              mean(var_name, na.rm=T),
              sd(var_name, na.rm=T)),
        col = "orange", lwd = 2,
        add = T)
}

## frequency table univariate 
# function outputs a nice frequency table (in data frame format)
freq_table_univ <- function(var_name, design_name) {
  formula_str <- paste0("~", var_name) # ~var_name
  var_formula <- as.formula(formula_str)
  absolute <- svytable(var_formula, design_name)
  percent <- round(prop.table(absolute)*100,1) %>% 
    data.frame() %>% 
    select(value_label = var_name, Freq) %>% 
    mutate(label = var_name)
  return(percent)
}

## function for most model fit under svyglm
# This function will output the following model fit statistics: Nagelkerke Pseudo R2, AIC; 
# note this function is used for models computed with svyglm (and the quasibinomial argument)
model_output_svyglm <- function(m) {
  list(
    Nagel = round(psrsq(m, "Nagel"),3),
    AIC = round(AIC(m),3)
  )
}

## function for LRT (under svyglm/quasibinomial)
# the function outputs the result of a LRT and a Wald Test on svyglm data
# it first calculates the null model, 
# then compares full model to null model using anova
# inputs: dv = the DV, df = the dataframe, m_full = full model
# Note that you need to input the DV as a string: "my_var"
lrt_fun_svyglm <- function(dv, df_w, m_full) {
  # null model
  null_formula <- as.formula(paste(dv, "~ 1")) # outputs: dv ~ 1
  m_null <- svyglm(null_formula, # is: dv ~ 1
                   family = quasibinomial(link="logit"),
                   design = df_w) 
  list(
    # LRT
    LRT = anova(m_null, m_full, method = "LRT"),
    # Wald 
    Wald = anova(m_null, m_full, method = "Wald")
  )
}

```

```{r coef names models, echo=F}
#### Set coefficient names for regression output ####
coef_names <- c("conspir_mean" = "Covid-19 conspiracy belief",
                "age" = "Age", 
                "sexf" = "Gender (female)",
                "educ_grA-levels" = "Education (A-levels or higher)",
                "pol_inter" = "Political interest",
                "ext_efficlow" = "External efficacy (low)",
                "swdsatisfied" = "Satisfaction with democracy",
                "lr" = "Left-right self-placement",
                "extrem_sq" = "Ideological extremism (sq.)",
                "Autoritarismus" = "Authoritarianism",
                "inst_trust" = "Inst. trust",
                "govt_oppnone" = "No party ID",
                "govt_oppopp." = "Support opposition party",
                "conspir_additive" = "Covid CT belief (additive)"
                )

```


```{r load all data needed, warning=F, message=F}
# wd
setwd("~/Dropbox/my_datasets")

# load data
# tm <- read_sav("tm2021.sav")
tm <- read_sav("ZA6345_v8-0-0.sav") # with data from Gesis
# head(tm[, c(30:35)]) #check
tm <- tm %>% 
  filter(welle == 2021) # filter for 2021 wave of survey

```

# Data Cleaning and Manipulation

To measure support for democracy and conceptions of democracy, the following variables were used. If not indicated otherwise, dummy variables were created where those who *"fully agree"* or *"mostly agree"* were coded as `1`, while those who *"mostly disagree"* or *"fully disagree"* were coded as `0`.

* `dem_idea`: Captures support for the idea of democracy and is based on item `V08`: "Democracy is the best of all political orders".  
* `dict`: Captures support for a dictatorship and is based on item `V12A`: "For the national interest, a dictatorship is the best form of government under certain conditions".  
* `dd`: Measures support for direct democracy and is based on item `V701A`: "The people, and not the politicians, should make our most important decisions".  
* `tech`: Captures a preference for expert-based decision-making and is based on item `V12EX`: "Important decisions in a democracy should be made by independent experts rather than by elected politicians".  

Further, to measure conceptions of democracy, participants were asked to think about democracy in general and to evaluate how important an element is for democracy. As the distribution of responses to these items was often skewed towards rating the element as important, we decided to code the dummy in such a way that only those who think the element is *"very important"* (value `4` on the original 4-point scale) receive the value `1`, while all others receive the value `0`.

* `elect`: Importance of free and fair elections (based on item `V08W`).  
* `responsv`: Preference for the delegate model of representation (`V08RS1`: "...that the elected politicians base their policies on the wishes of the citizens").  
* `delib`: Support for deliberative democracy, based on item `V08DD`: "...that political decisions are developed in close dialogue with citizens and those affected".  
* `free_speech`: Importance of free speech (`V12MF`).  
* `opposition`: Importance of horizontal accountability, measured as: "...that government is controlled by a strong opposition" (`V08OP`) (only used in the robustness checks in the Appendix).  
* `minority_rights`: Importance of minority rights (`V08MI`) (only used in the robustness checks in the Appendix).  


Our main independent variable is Covid-19 conspiracy belief:

* `conspir_mean` was operationalized by creating a mean index of two items that were each measured on a 4-point scale. Higher values on the mean index indicate higher conspiracy belief. The 2 items are:
  * `COR_E5`: "There are secret organizations that have a great influence on political decisions during the Corona crisis"
  * `COR_E11`: "The government deliberately frightened the population during the Corona crisis in order to enforce massive restrictions on fundamental rights".


The following controls were introduced:

* `age`: Respondents' age.  
* `sex`: Respondents' gender.  
* `educ_gr`: Level of education, coded as a dummy variable distinguishing between those with at least A-levels and those without A-levels.  
* `pol_inter`: Political interest measured on a 5-point scale.  
* `lr`: Left-right self-placement measured on a 7-point scale (1 = very far-left, 7 = very far-right).  
* `extrem_sq`: Operationalized as the squared distance from the center of the left-right self-placement scale.  
* `ext_effic`: External efficacy coded as a dummy variable based on item `V139J`: "People like me don’t have a say about what the government does."  
* `swd`: Dummy variable capturing satisfaction with democracy, coded from item `V07`: "All in all, how satisfied or dissatisfied are you with the way democracy works in Germany."  
* `inst_trust`: Additive index capturing political trust based on two items, each measured on a 5-point scale, asking respondents to indicate their trust in the federal (`V09A`) and regional (`V09B`) government (only used in the robustness checks in the Appendix).  



```{r data manipulation}

#### DVs ####
tm <- tm %>% 
  mutate(
    across(c(V08, V12D, V08W, V08RS1, V08MF, V701A, V12EX, V08DD, V08OP, V08MI),
           ~replace(.x, .x > 87, NA)),
    dem_idea = ifelse(V08>2, 1, 0), # Support for democracy
    dict = ifelse(V12D>2, 1, 0), # Support for dictatorship
    elect = ifelse(V08W>3, 1, 0), # importance of elections
    responsv = ifelse(V08RS1>3, 1, 0), # importance of delegate model of representation
    free_speech = ifelse(V08MF>3, 1, 0), # importance of free speech
    dd = ifelse(V701A>2, 1, 0), # direct democracy
    tech = ifelse(V12EX>2, 1, 0), # expert-based decision-making
    delib = ifelse(V08DD>3, 1, 0), # importance of deliberation
    opposition = ifelse(V08OP>3, 1, 0), # importance of opposition/horizontal accountability
    minority_rights = ifelse(V08MI>3, 1, 0), # importance of minority rights
    across(c(dem_idea, dict, elect, responsv, free_speech, dd, tech, delib, opposition, minority_rights),
           ~ factor(.x,
                    levels = c(0,1)))
  )


# more manipulation of DV for ordinal logistic regressions
tm <- tm %>% 
  mutate(
    dem_idea4 = factor(V08, levels=c(1:4)),
    dict4 = factor(V12D, levels=c(1:4)), 
    elect4 = factor(V08W, levels=c(1:4)), 
    responsv4 = factor(V08RS1, levels=c(1:4)), 
    free_speech4 = factor(V08MF, levels=c(1:4)),
    dd4 = factor(V701A, levels=c(1:4)), 
    tech4 = factor(V12EX, levels=c(1:4)), 
    delib4 = factor(V08DD, levels=c(1:4)), 
  )


#### IVs and controls ####

# Conspiracy belief
tm <- tm %>% 
  mutate(
    ## Dummy
    across(c(COR_E5, COR_E11),
           ~replace(.x, .x > 87, NA)),
    core5_gr = ifelse(COR_E5>2, 1, 0),
    core11_gr = ifelse(COR_E11>2, 1, 0),
    conspir_count = core5_gr + core11_gr,
    conspir_dummy = ifelse(conspir_count>0, 1, 0),
    across(c(core5_gr, core11_gr, conspir_dummy),
           ~factor(.x,
                   levels = c(0,1),
                   labels = c("no", "yes"))),
    ## Mean scale
    conspir_mean = (as.numeric(COR_E5) + as.numeric(COR_E11))/2,
    ## Additive index
    conspir_additive = as.numeric(COR_E5) + as.numeric(COR_E11)
  )


# Socio-demographic and other controls
tm <- tm %>% 
  mutate(
    age = as.numeric(alter),
    sex = factor(sex, 
                 levels = c(1,2),
                 labels = c("m", "f")),
    across(c(bildung_neu, bildung_brfl),
           ~replace(.x, .x >5, NA)),
    educ_gr = case_when(
      bildung_neu > 4 |
        bildung_neu < 5 & bildung_brfl == 5 ~ 1,
      TRUE ~ 0),
    educ_gr = factor(educ_gr, 
                        levels = c(0, 1), 
                        labels = c("less than A-levels", "A-levels")),
    # Political interest
    pol_inter = as.numeric(V06),
    # Ideology
    ## L/R self-placement
    lr = replace(V19, V19 > 87, NA),
    lr = as.numeric(lr),
    # Extremism
    extrem = case_when(lr == 1 | lr == 7 ~ 3,
                       lr == 2 | lr == 6 ~ 2,
                       lr == 3 | lr == 5 ~ 1,
                       lr == 4 ~ 0),
    extrem_sq = extrem^2,
    # Autoritarismus
    Autoritarismus = ifelse((is.na(V14) + is.na(V15)) > 1, NA, 
                            rowMeans(across(c(V14, V15)), na.rm = T)),
    # partyID
    party_id = case_when(V20 == 0 ~ "none",
                         V20 == 1 ~ "CDU",
                         V20 == 2 ~ "SPD",
                         V20 == 3 ~ "Left",
                         V20 == 4 ~ "FDP",
                         V20 == 5 ~ "Greens",
                         V20 == 8 ~ "AfD",
                         V20 == 6 |
                           V20 == 7 |
                           V20 == 10 ~ "other"),
    party_id = factor(party_id),
    party_id = relevel(party_id, ref = "none"),
    # Supporter govt. vs opposition party
    govt_opp = case_when(V20 == 0 ~ "none",
                         V20 == 1 |
                           V20 == 2 ~ "govt.",
                         V20 %in% c(3, 4, 5, 6, 7, 8, 10) ~ "opp."),
    govt_opp = factor(govt_opp),
    govt_opp = relevel(govt_opp, ref = "govt."),
    # Efficacy
    ext_effic = ifelse(V139J>2,1,0),
    ext_effic = factor(ext_effic,
                   levels = c(0,1),
                   labels = c("high", "low")),
    # trust & SWD
    inst_trust = V09A + V09B,
    swd = ifelse(V07>2,1,0),
    swd = factor(swd,
                 levels = c(0,1),
                 labels = c("dissatisfied", "satisfied"))
    
  )


# select vars we need (to make compiling faster)
tm <- tm %>% 
  select(
    # DVs (dummies)+
    dem_idea, dict, elect, responsv, free_speech, dd, tech, delib, opposition, minority_rights,
    # DVs (for ordinal regression)
    dem_idea4, dict4, elect4, responsv4, free_speech4, dd4, tech4, delib4,
    # IVs and controls
    conspir_mean, conspir_count, conspir_dummy, conspir_additive, core5_gr, core11_gr,
    age, sex, educ_gr, pol_inter, lr, extrem, extrem_sq, Autoritarismus,
    party_id, govt_opp, ext_effic, inst_trust, swd,
    # All raw vars democracy
    V08, V12D, V701A, V12EX, V08PG, V08SG, V08CG, V08MF, V08W, V08OP, V08MI, 
    V08RS1, V08RS2, V08RS3, V08EZ, V08DR, V08DD, V08AC,
    # Weight
    persgew,
    # Raw vars recoded (backup)
    COR_E5, COR_E11, alter, bildung_neu, bildung_brfl, V06, V19, V20, V14, V15, V139J, V09A, V09B, V07
  )


# surveydesign object
tm_w <- svydesign(id=~0, weights = ~persgew, data = tm)

tm_all <- tm # for null models

```

```{r check data manipulation, include=F, message=F, warning=F}
tm %>% 
  select(dem_idea, dict, elect, opposition, responsv, free_speech, dd, tech, delib) %>% 
  glimpse()

table(tm$V12D, useNA = "ifany")
table(tm$dict, useNA = "ifany")
table(tm$V701A, useNA = "ifany")
table(tm$dd, useNA = "ifany")
table(tm$V12EX, useNA = "ifany")
table(tm$tech, useNA = "ifany")
table(tm$V08W, useNA = "ifany")
table(tm$elect, useNA = "ifany")
table(tm$V08RS1, useNA = "ifany")
table(tm$responsv, useNA = "ifany")
table(tm$V08MF, useNA = "ifany")
table(tm$free_speech, useNA = "ifany")
table(tm$V08DD, useNA = "ifany")
table(tm$deli, useNA = "ifany")

table(tm$conspir_mean, useNA = "ifany")
table(tm$COR_E5, useNA = "ifany")
table(tm$core5_gr, useNA = "ifany")

tm %>% 
  select(age, sex, educ_gr, pol_inter,
         lr, extrem, extrem_sq, Autoritarismus,
         party_id, govt_opp, ext_effic, swd, inst_trust) %>% 
  glimpse()

table(tm$V19, useNA = "ifany")
table(tm$lr, useNA = "ifany")
table(tm$extrem, useNA = "ifany")
table(tm$extrem_sq, useNA = "ifany")

table(tm$V139J, useNA = "ifany")
table(tm$ext_effic, useNA = "ifany")

table(tm$V20, useNA = "ifany")
table(tm$party_id, useNA = "ifany")
table(tm$govt_opp, useNA = "ifany")
```


# Explore DV (and main IV)

Let's look at the distribution of our DVs to decide what models to compute. 

## Distribution of DVs
```{r histograms of DVs, fig.width=10, fig.height=7}
# hist/boxplot overview -> they are all skewed!
par(mfrow=c(3,3))
hist_norm(tm$V08)
hist_norm(tm$V12D)
hist_norm(tm$V08W)
hist_norm(tm$V08OP)
hist_norm(tm$V08RS1)
hist_norm(tm$V08MF)
hist_norm(tm$V701A)
hist_norm(tm$V12EX)
hist_norm(tm$V08DD)
par(mfrow=c(1,1))
```

Most of our DVs are extremely skewed, and none are approximately normally distributed. Therefore, we will use logistic regression with dummy variables in all our analyses. 

Additionally, the variables from the battery that assess how important certain elements are for democracy (`V08W`, `V08OP`, `V08MF`, `V08RS1`, `V08DD`) are recoded into dummy variables using 3 as the cut-off (we originally used a 4-point scale). This means that only the response category **"very important"** is coded as `1` in the dummy variable, while all remaining values are coded as `0`.


## Distribution of CT belief

Next, let's assess how wide-spread Covid-19 related conspiracy beliefs are in our sample.

```{r freq table CT belief}
conspir_count <- freq_table_univ("conspir_count", tm_w) 
core5 <- freq_table_univ("core5_gr", tm_w) 
core11 <- freq_table_univ("core11_gr", tm_w) 

df <- bind_rows(conspir_count, core5, core11) %>% 
  mutate(label = case_when(label == "conspir_count" ~ "# CTs believed",
                           label == "core5_gr" ~ "Secret organizations",
                           label == "core11_gr" ~ "Deliberately frightened ")
  ) 
df %>% 
  select(label, response = value_label, share = Freq) %>% 
  kbl(caption = "How wide spread is CT belief in the sample") %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

```

We see that the majority of our respondents does not believe in any of the two Covid-19 related conspiracy theories, while 44.3 % of the respondents support at least one and 18.7 % indicated support for both items. 



# Bivariate Analysis

We now want to examine the association between **Covid-19 conspiracy beliefs** and **support for** as well as **conceptions of democracy**. To do so, we compute a correlation matrix (using the `indep_test` function from the `wdm` package. This function provides Spearman's rho and p-values while allowing us to incorporate our survey weight).

Here, we only assess correlations for variables that we theoretically assumed to be linked to CT belief. However, in the section [Corrplot with all items from democracy battery](#corrplot-with-all-items-from-democracy-battery), we also explore bivariate associations with **all items** from the democracy battery. There, find that—except for **minority rights**, which is already discussed in the appendix, none of the other associations are significant.


```{r corr plot DVs, fig.width=9, fig.height=9}
# DVs
demo_main <- c("conspir_mean", "V08", "V12D", "V08W", "V08RS1", "V701A", "V08DD", "V12EX", "V08MF")

# function, computing weigthed corr coefficient with indep_test
# that's the only way we get coeffs AND p-values!
weighted_corr <- function(var1, var2, data, weights) {
  indep_test(
    x = data[[var1]], 
    y = data[[var2]], 
    weights = data[[weights]], 
    method = "spearman"
  )
}

# empty df to store results of loop
results <- data.frame(V1 = character(), V2 = character(), coeff = numeric(), p = numeric())

# loop
for (i in 1:(length(demo_main) - 1)) {
  for (j in (i + 1):length(demo_main)) {
    # varnames
    var1 <- demo_main[i]
    var2 <- demo_main[j]

    # run weigthed corrs function
    test <- weighted_corr(var1, var2, data = tm, weights = "persgew") 
    
    # store coeff and p-value
    rho <- test$estimate
    p_value <- test$p_value

    # append loop output to results df
    results <- rbind(results, data.frame(V1 = var1, V2 = var2,
                                         coeff = rho,
                                         p = p_value))
  }
}

# results # check

# now, we need to get the "results" df into wide format / or actually a matrix to apply it to corrplot

# diagonal correlations are set to 1 (self-correlation)
diag_entries <- data.frame(
  V1 = unique(c(results$V1, results$V2)),
  V2 = unique(c(results$V1, results$V2)),
  coeff = 1,
  p = NA
)

# join self-correlations df with actual results df
results_full <- bind_rows(results, diag_entries) %>%
  # all pairwise correlations are present in both directions
  bind_rows(results %>% rename(V1 = V2, V2 = V1))

results_full <- results_full %>%
  distinct(V1, V2, .keep_all = T)

# wide format for corr matrix style
corr_matrix <- results_full %>%
  select(V1, V2, coeff) %>%
  pivot_wider(names_from = V2, values_from = coeff)

# corr_matrix  check

# set 1st column as rownames and then remove it from df
corr_matrix <- as.data.frame(corr_matrix)
rownames(corr_matrix) <- corr_matrix$V1
corr_matrix <- corr_matrix %>% 
  select(-V1)

# change order (conspir_mean first), so diagonal in corrplot is applied correctly
corr_matrix <- corr_matrix %>% 
  select(conspir_mean, V08, V12D, V08W, V08RS1, V701A, V08DD, V12EX, V08MF)

# covert df to matrix to use it in corrplot
corr_matrix <- as.matrix(corr_matrix)

# same with p
p_matrix <- results_full %>%
  select(V1, V2, p) %>%
  pivot_wider(names_from = V2, values_from = p)

# set 1st column as rownames and then remove it from df
p_matrix <- as.data.frame(p_matrix)
rownames(p_matrix) <- p_matrix$V1
p_matrix <- p_matrix %>% 
  select(-V1)

# change order (conspir_mean first), so diagonal in corrplot is applied correctly
p_matrix <- p_matrix %>% 
  select(conspir_mean, V08, V12D, V08W, V08RS1, V701A, V08DD, V12EX, V08MF)

# covert df to matrix to use it in corrplot
p_matrix <- as.matrix(p_matrix)


# customize labels for corr matrix and p matrix
# change the rownames and colnames for that:
rownames(corr_matrix) <- c("conspircay belief", "idea of democracy", "dictatorship", "elections", "responsiveness", "direct democracy", "deliberative democracy", "technocracy", "freedom of speech")
colnames(corr_matrix) <- c("conspircay belief", "idea of democracy", "dictatorship", "elections", "responsiveness", "direct democracy", "deliberative democracy", "technocracy", "freedom of speech")

rownames(p_matrix) <- c("conspircay belief", "idea of democracy", "dictatorship", "elections", "responsiveness", "direct democracy", "deliberative democracy", "technocracy", "freedom of speech")
colnames(p_matrix) <- c("conspircay belief", "idea of democracy", "dictatorship", "elections", "responsiveness", "direct democracy", "deliberative democracy", "technocracy", "freedom of speech")

# the plot
corrplot(corr_matrix,
         p.mat = p_matrix, # get manual pvalues data
         method = "circle",
         type = "upper",
         insig ="pch", # cross out insignif. values
         diag = F,
         tl.col = "black",
         tl.srt = 45, # aligns top labels 45 degrees
         addCoef.col = "white", # add corr coeff values inside circles
         is.corr = F)


```



# Regression Models

Note that due to the simple survey design of our study (no clustering or stratification), we opted for using `glm()` instead of `svyglm()`. However, to ensure robustness, we also estimated the models using `svyglm()`, and the results can be found in the appendix (see [Models using svyglm](#models-using-svyglm)).


## Support for democracy vs. dictatorship

```{r main models idea of democracy and support for dict}
## support for idea of democracy
dem_idea_full <- glm(dem_idea~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

## support for dictatorship
dict_full <- glm(dict~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

```

```{r model summary idea of democracy and support for dict, warning=F, message=F}
modelsummary(
  list("Idea of democracy" = dem_idea_full,
       "Dictatorship" = dict_full),
  exponentiate = T, # get OR
  stars = T,
  output = "tinytable",
  statistic = "conf.int",
  gof_omit = "RMSE|R2|Deviance|F|AIC|BIC|Log.Lik",
  title = "Logistic Regression Models:Support for Democracy (Odds Ratios)",
  coef_rename = coef_names
)
```

#### What do the results tell us?

In the full models – after controlling not only for socio-demographics but also some standard predictors often associated with support for democracy – we find that Covid-19 conspiracy belief is *not* significantly associated with either support for the **idea of democracy** or **support for a dictatorship**.


#### Model fit
```{r model fit main models idea of democracy and support for dict}
## support for idea of democracy
# select vars we need so null model and full model are computed on same # of cases
tm <- tm_all %>% 
  select(dem_idea, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dem_idea", dem_idea_full) # F-Test
quasi_mcfadden("dem_idea", tm_w, dem_idea_full) # 1-(deviance(full)/deviance(null))

## support for dictatorship
# select vars we need so null model and full model are computed on same # of cases
tm <- tm_all %>% 
  select(dict, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dict", dict_full)
quasi_mcfadden("dict", tm_w, dict_full)


tm <- tm_all # reset
```



## Conceptions of democracy 

```{r main models conceptions}
## elections
elect_full <- glm(elect~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                  family = quasibinomial(link = "logit"),
                  weights = persgew,
                  data = tm)

## responsiveness
responsv_full <- glm(responsv~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

## direct democracy
dd_full <- glm(dd~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
               family = quasibinomial(link = "logit"),
               weights = persgew,
               data = tm)

## deliberative democracy
delib_full <- glm(delib~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                  family = quasibinomial(link = "logit"),
                  weights = persgew,
                  data = tm)

## technocracy
tech_full <- glm(tech~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                 family = quasibinomial(link = "logit"),
                 weights = persgew,
                 data = tm)

## free speech
free_full <- glm(free_speech~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                 family = quasibinomial(link = "logit"),
                 weights = persgew,
                 data = tm)

```

```{r model summary conceptions, message=F, warning=F}
modelsummary(
  list("Elections" = elect_full,
       "Responsiveness" = responsv_full,
       "Direct Dem." = dd_full,
       "Delib. Dem." = delib_full,
       "Technocracy" = tech_full,
       "Free speech" = free_full),
  exponentiate = T, # get OR
  stars = T,
  output = "tinytable",
  statistic = "conf.int",
  gof_omit = "RMSE|R2|Deviance|F|AIC|BIC|Log.Lik",
  title = "Logistic Regression Models: Conceptions of Democracy (Odds Ratios)",
  coef_rename = coef_names
)
```

#### What do the results tell us?

In our main models, Covid-19 CT beliefs are significantly and....

* negatively associated with regarding free and fair **elections** as an important component of democracy
* positively associated with support for **direct democracy**
* ... and **technocracy**
* as well as support for the delegate model of representation. 


#### Model fit
```{r model fit main models conceptions}
## elections
# select vars we need
tm <- tm_all %>% 
  select(elect, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("elect", elect_full)
quasi_mcfadden("elect", tm_w, elect_full)

## responsiveness
# select vars we need
tm <- tm_all %>% 
  select(responsv, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("responsv", responsv_full)
quasi_mcfadden("responsv", tm_w, responsv_full)

## direct democracy
# select vars we need
tm <- tm_all %>% 
  select(dd, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dd", dd_full)
quasi_mcfadden("dd", tm_w, dd_full)

## deliberative democracy
# select vars we need
tm <- tm_all %>% 
  select(delib, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("delib", delib_full)
quasi_mcfadden("delib", tm_w, delib_full)

## technocracy
# select vars we need
tm <- tm_all %>% 
  select(tech, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("tech", tech_full)
quasi_mcfadden("tech", tm_w, tech_full)

## free speech
# select vars we need
tm <- tm_all %>% 
  select(free_speech, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("free_speech", free_full)
quasi_mcfadden("free_speech", tm_w, free_full)


tm <- tm_all # reset

```



# APPENDIX: Robustness Checks and Further Model Specifications

In this section, we compute additional model specifications to assess the robustness of our findings. These include:

* Models with **socio-demographic controls only**.  
* Models including **party ID**, indicating whether a respondent supports a government party, an opposition party, or has no party ID at all.  
* Models adding **institutional trust** as a predictor.  

Additionally, we assess the association between **Covid-19 conspiracy beliefs** and further **elements of democracy**, namely 

* **minority rights** (which showed a significant bivariate association) and
* **horizontal accountability**.  

Finally, we present models using the more robust `svyglm` and ordinal logistic regressions.  



## Models with Socio-Demographic Controls Only

We realized that we **forgot to update** the socio-demographics-only models in the regression tables. In an earlier version of the paper, we used an **additive index** instead of a **mean index** to operationalize CT beliefs. As a result, the odds ratios (OR) presented here—using the CT belief mean scale—differ slightly from those in the final paper/supplement.

However, it's important to note that the **significance of our main IV (Covid-19 CT belief)** remains **unaffected**.  

The models using the **additive index** are presented below for comparison.


### Socio-demographics only models with CT belief mean index

```{r socio-demographic controls only}
# support for idea of democracy
dem_idea_sd <- glm(dem_idea~conspir_mean+age+sex+educ_gr,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# support for dictatorship
dict_sd <- glm(dict~conspir_mean+age+sex+educ_gr,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# elections
elect_sd <- glm(elect~conspir_mean+age+sex+educ_gr,
                  family = quasibinomial(link = "logit"),
                  weights = persgew,
                  data = tm)

# responsiveness
responsv_sd <- glm(responsv~conspir_mean+age+sex+educ_gr,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# direct democracy
dd_sd <- glm(dd~conspir_mean+age+sex+educ_gr,
               family = quasibinomial(link = "logit"),
               weights = persgew,
               data = tm)

# deliberative democracy
delib_sd <- glm(delib~conspir_mean+age+sex+educ_gr,
                  family = quasibinomial(link = "logit"),
                  weights = persgew,
                  data = tm)

# technocracy
tech_sd <- glm(tech~conspir_mean+age+sex+educ_gr,
                 family = quasibinomial(link = "logit"),
                 weights = persgew,
                 data = tm)

# free speech
free_sd <- glm(free_speech~conspir_mean+age+sex+educ_gr,
                 family = quasibinomial(link = "logit"),
                 weights = persgew,
                 data = tm)

```

```{r summary socio-demographic controls only mean index, message=F, warning=F}
modelsummary(
  list("Idea of democracy" = dem_idea_sd,
       "Dictatorship" = dict_sd,
       "Elections" = elect_sd,
       "Responsiveness" = responsv_sd,
       "Direct Dem." = dd_sd,
       "Delib. Dem." = delib_sd,
       "Technocracy" = tech_sd,
       "Free speech" = free_sd),
  exponentiate = T, # get OR
  stars = T,
  output = "tinytable",
  statistic = "conf.int",
  gof_omit = "RMSE|R2|Deviance|F|AIC|BIC|Log.Lik",
  title = "Logistic Regression Models: Socio-Demographic Controls Only - Mean Index (Odds Ratios)",
  coef_rename = coef_names
)
```

```{r model fit mean socio-demographic controls only mean index, include=F}
## support for idea of democracy
# select vars we need so null model and full model are computed on same # of cases
tm <- tm_all %>% 
  select(dem_idea, conspir_mean, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dem_idea", dem_idea_sd) # F-Test
quasi_mcfadden("dem_idea", tm_w, dem_idea_sd) # 1-(deviance(full)/deviance(null))

## support for dictatorship
# select vars we need so null model and full model are computed on same # of cases
tm <- tm_all %>% 
  select(dict, conspir_mean, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dict", dict_sd)
quasi_mcfadden("dict", tm_w, dict_sd)

## elections
# select vars we need
tm <- tm_all %>% 
  select(elect, conspir_mean, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("elect", elect_sd)
quasi_mcfadden("elect", tm_w, elect_sd)

## responsiveness
# select vars we need
tm <- tm_all %>% 
  select(responsv, conspir_mean, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("responsv", responsv_sd)
quasi_mcfadden("responsv", tm_w, responsv_sd)

## direct democracy
# select vars we need
tm <- tm_all %>% 
  select(dd, conspir_mean, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dd", dd_sd)
quasi_mcfadden("dd", tm_w, dd_sd)

## deliberative democracy
# select vars we need
tm <- tm_all %>% 
  select(delib, conspir_mean, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("delib", delib_sd)
quasi_mcfadden("delib", tm_w, delib_sd)

## technocracy
# select vars we need
tm <- tm_all %>% 
  select(tech, conspir_mean, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("tech", tech_sd)
quasi_mcfadden("tech", tm_w, tech_sd)

## free speech
# select vars we need
tm <- tm_all %>% 
  select(free_speech, conspir_mean, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("free_speech", free_sd)
quasi_mcfadden("free_speech", tm_w, free_sd)


tm <- tm_all # reset

```


### Socio-demographics only models with additive index

```{r additive index}
# support for idea of democracy
dem_idea_sd <- glm(dem_idea~conspir_additive+age+sex+educ_gr,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# support for dictatorship
dict_sd <- glm(dict~conspir_additive+age+sex+educ_gr,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# elections
elect_sd <- glm(elect~conspir_additive+age+sex+educ_gr,
                  family = quasibinomial(link = "logit"),
                  weights = persgew,
                  data = tm)

# responsiveness
responsv_sd <- glm(responsv~conspir_additive+age+sex+educ_gr,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# direct democracy
dd_sd <- glm(dd~conspir_additive+age+sex+educ_gr,
               family = quasibinomial(link = "logit"),
               weights = persgew,
               data = tm)

# deliberative democracy
delib_sd <- glm(delib~conspir_additive+age+sex+educ_gr,
                  family = quasibinomial(link = "logit"),
                  weights = persgew,
                  data = tm)

# technocracy
tech_sd <- glm(tech~conspir_additive+age+sex+educ_gr,
                 family = quasibinomial(link = "logit"),
                 weights = persgew,
                 data = tm)

# free speech
free_sd <- glm(free_speech~conspir_additive+age+sex+educ_gr,
                 family = quasibinomial(link = "logit"),
                 weights = persgew,
                 data = tm)
```

```{r summary additive index}
modelsummary(
  list("Idea of democracy" = dem_idea_sd,
       "Dictatorship" = dict_sd,
       "Elections" = elect_sd,
       "Responsiveness" = responsv_sd,
       "Direct Dem." = dd_sd,
       "Delib. Dem." = delib_sd,
       "Technocracy" = tech_sd,
       "Free speech" = free_sd),
  exponentiate = T, # get OR
  stars = T,
  output = "tinytable",
  statistic = "conf.int",
  gof_omit = "RMSE|R2|Deviance|F|AIC|BIC|Log.Lik",
  title = "Logistic Regression Models: Socio-demographic Controls Only - Additive Index (Odds Ratios)",
  coef_rename = coef_names
)
```

```{r model fit mean socio-demographic controls only additive index, include=F}
## support for idea of democracy
# select vars we need so null model and full model are computed on same # of cases
tm <- tm_all %>% 
  select(dem_idea, conspir_additive, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dem_idea", dem_idea_sd) # F-Test
quasi_mcfadden("dem_idea", tm_w, dem_idea_sd) # 1-(deviance(full)/deviance(null))

## support for dictatorship
# select vars we need so null model and full model are computed on same # of cases
tm <- tm_all %>% 
  select(dict, conspir_additive, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dict", dict_sd)
quasi_mcfadden("dict", tm_w, dict_sd)

## elections
# select vars we need
tm <- tm_all %>% 
  select(elect, conspir_additive, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("elect", elect_sd)
quasi_mcfadden("elect", tm_w, elect_sd)

## responsiveness
# select vars we need
tm <- tm_all %>% 
  select(responsv, conspir_additive, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("responsv", responsv_sd)
quasi_mcfadden("responsv", tm_w, responsv_sd)

## direct democracy
# select vars we need
tm <- tm_all %>% 
  select(dd, conspir_additive, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dd", dd_sd)
quasi_mcfadden("dd", tm_w, dd_sd)

## deliberative democracy
# select vars we need
tm <- tm_all %>% 
  select(delib, conspir_additive, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("delib", delib_sd)
quasi_mcfadden("delib", tm_w, delib_sd)

## technocracy
# select vars we need
tm <- tm_all %>% 
  select(tech, conspir_additive, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("tech", tech_sd)
quasi_mcfadden("tech", tm_w, tech_sd)

## free speech
# select vars we need
tm <- tm_all %>% 
  select(free_speech, conspir_additive, age, sex, educ_gr, persgew) %>% 
  na.omit()

# model fit
modelfit_fun_glm("free_speech", free_sd)
quasi_mcfadden("free_speech", tm_w, free_sd)


tm <- tm_all # reset

```


#### What do the results tell us?

If we compute basic models introducing **socio-demographic controls** (age, gender, education) only, we find that **Covid-19 conspiracy beliefs** are associated with all our DVs—except "free speech".

* **Negative Associations:**  
  - CT beliefs are negatively associated with **support for the idea of democracy** as well as with viewing **free and fair elections** as an important element of democracy.  

* **Positive Associations:**  
  - CT beliefs are positively associated with **alternatives to representative democracy**, namely:  
    - **Direct democracy**  
    - **Technocracy**  
    - **Deliberative democracy**  
  - Further, CT belief is positively linked to **support for a dictatorship under certain circumstances**.  
  - Those who believe in Covid-19 conspiracy theories also favor the **delegate model of representation** (referred to as the "responsiveness").  



## Models with Party ID

Next, we control whether our results remain robust after controlling for supporters of government vs. supporters of opposition parties. 

This is the case, with two slight changes:

* Conspiracy beliefs are significant in the extended main model for support for democracy, but only at the 90% level (the coefficient is n.s. in the main model).  
* The significance of the Covid-19 CT beliefs coefficient drops to the 90% level in the model measuring the importance of free and fair elections for democracy.  

```{r models with party id}
# support for idea of democracy
dem_idea_full <- glm(dem_idea~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+govt_opp+Autoritarismus,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# support for dictatorship
dict_full <- glm(dict~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+govt_opp+Autoritarismus,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# elections
elect_full <- glm(elect~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+govt_opp+Autoritarismus,
                  family = quasibinomial(link = "logit"),
                  weights = persgew,
                  data = tm)

# responsiveness
responsv_full <- glm(responsv~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+govt_opp+Autoritarismus,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# direct democracy
dd_full <- glm(dd~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+govt_opp+Autoritarismus,
               family = quasibinomial(link = "logit"),
               weights = persgew,
               data = tm)

# deliberative democracy
delib_full <- glm(delib~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+govt_opp+Autoritarismus,
                  family = quasibinomial(link = "logit"),
                  weights = persgew,
                  data = tm)

# technocracy
tech_full <- glm(tech~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+govt_opp+Autoritarismus,
                 family = quasibinomial(link = "logit"),
                 weights = persgew,
                 data = tm)

# free speech
free_full <- glm(free_speech~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+govt_opp+Autoritarismus,
                 family = quasibinomial(link = "logit"),
                 weights = persgew,
                 data = tm)

```

```{r model summary party id model, warning=F, message=F}
modelsummary(
  list("Idea of democracy" = dem_idea_full,
       "Dictatorship" = dict_full,
       "Elections" = elect_full,
       "Responsiveness" = responsv_full,
       "Direct Dem." = dd_full,
       "Delib. Dem." = delib_full,
       "Technocracy" = tech_full,
       "Free speech" = free_full),
  exponentiate = T, # get OR
  stars = T,
  output = "tinytable",
  statistic = "conf.int",
  gof_omit = "RMSE|R2|Deviance|F|AIC|BIC|Log.Lik",
  title = "Logistic Regression Models with Party ID (Odds Ratios)",
  coef_rename = coef_names,
  notes = "Note that party ID was operationalized as support for party in govt., support for party excluded from govt.; no party identification. The reference category is: supported party in government (SPD/CDU government at federal level)"
)
```

```{r model fit party id models, include=F}
## support for idea of democracy
# select vars we need so null model and full model are computed on same # of cases
tm <- tm_all %>% 
  select(dem_idea, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, govt_opp) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dem_idea", dem_idea_full) # F-Test
quasi_mcfadden("dem_idea", tm_w, dem_idea_full) # 1-(deviance(full)/deviance(null))

## support for dictatorship
# select vars we need so null model and full model are computed on same # of cases
tm <- tm_all %>% 
  select(dict, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, govt_opp) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dict", dict_full)
quasi_mcfadden("dict", tm_w, dict_full)

## elections
# select vars we need
tm <- tm_all %>% 
  select(elect, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, govt_opp) %>% 
  na.omit()

# model fit
modelfit_fun_glm("elect", elect_full)
quasi_mcfadden("elect", tm_w, elect_full)

## responsiveness
# select vars we need
tm <- tm_all %>% 
  select(responsv, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, govt_opp) %>% 
  na.omit()

# model fit
modelfit_fun_glm("responsv", responsv_full)
quasi_mcfadden("responsv", tm_w, responsv_full)

## direct democracy
# select vars we need
tm <- tm_all %>% 
  select(dd, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, govt_opp) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dd", dd_full)
quasi_mcfadden("dd", tm_w, dd_full)

## deliberative democracy
# select vars we need
tm <- tm_all %>% 
  select(delib, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, govt_opp) %>% 
  na.omit()

# model fit
modelfit_fun_glm("delib", delib_full)
quasi_mcfadden("delib", tm_w, delib_full)

## technocracy
# select vars we need
tm <- tm_all %>% 
  select(tech, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, govt_opp) %>% 
  na.omit()

# model fit
modelfit_fun_glm("tech", tech_full)
quasi_mcfadden("tech", tm_w, tech_full)

## free speech
# select vars we need
tm <- tm_all %>% 
  select(free_speech, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, govt_opp) %>% 
  na.omit()

# model fit
modelfit_fun_glm("free_speech", free_full)
quasi_mcfadden("free_speech", tm_w, free_full)


tm <- tm_all # reset


```


## Models with Institutional Trust

While our models already include external efficacy (`ext_effic`) and satisfaction with democracy (`swd`) as predictors - both of which, especially the former, show strong associations with CT beliefs in other studies (potential overcontrolling?) - we now add **institutional trust** (`inst_trust`) as an additional robustness check.

We observe one slight change: the coefficient for CT beliefs in the **responsiveness model** drops to the **90% confidence level**.


```{r models with trust}
# support for idea of democracy
dem_idea_full <- glm(dem_idea~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus+inst_trust,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# support for dictatorship
dict_full <- glm(dict~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus+inst_trust,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# elections
elect_full <- glm(elect~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus+inst_trust,
                  family = quasibinomial(link = "logit"),
                  weights = persgew,
                  data = tm)

# responsiveness
responsv_full <- glm(responsv~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus+inst_trust,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# direct democracy
dd_full <- glm(dd~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus+inst_trust,
               family = quasibinomial(link = "logit"),
               weights = persgew,
               data = tm)

# deliberative democracy
delib_full <- glm(delib~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus+inst_trust,
                  family = quasibinomial(link = "logit"),
                  weights = persgew,
                  data = tm)

# technocracy
tech_full <- glm(tech~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus+inst_trust,
                 family = quasibinomial(link = "logit"),
                 weights = persgew,
                 data = tm)

# free speech
free_full <- glm(free_speech~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus+inst_trust,
                 family = quasibinomial(link = "logit"),
                 weights = persgew,
                 data = tm)
```

```{r model summary for models with trust, warning=F, message=F}
modelsummary(
  list("Idea of democracy" = dem_idea_full,
       "Dictatorship" = dict_full,
       "Elections" = elect_full,
       "Responsiveness" = responsv_full,
       "Direct Dem." = dd_full,
       "Delib. Dem." = delib_full,
       "Technocracy" = tech_full,
       "Free speech" = free_full),
  exponentiate = T, # get OR
  stars = T,
  output = "tinytable",
  statistic = "conf.int",
  gof_omit = "RMSE|R2|Deviance|F|AIC|BIC|Log.Lik",
  title = "Logistic Regression Models with Trust (Odds Ratios)",
  coef_rename = coef_names
)
```

```{r moel fit trust models, include=F}
## support for idea of democracy
# select vars we need so null model and full model are computed on same # of cases
tm <- tm_all %>% 
  select(dem_idea, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, inst_trust) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dem_idea", dem_idea_full) # F-Test
quasi_mcfadden("dem_idea", tm_w, dem_idea_full) # 1-(deviance(full)/deviance(null))

## support for dictatorship
# select vars we need so null model and full model are computed on same # of cases
tm <- tm_all %>% 
  select(dict, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, inst_trust) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dict", dict_full)
quasi_mcfadden("dict", tm_w, dict_full)

## elections
# select vars we need
tm <- tm_all %>% 
  select(elect, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, inst_trust) %>% 
  na.omit()

# model fit
modelfit_fun_glm("elect", elect_full)
quasi_mcfadden("elect", tm_w, elect_full)

## responsiveness
# select vars we need
tm <- tm_all %>% 
  select(responsv, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, inst_trust) %>% 
  na.omit()

# model fit
modelfit_fun_glm("responsv", responsv_full)
quasi_mcfadden("responsv", tm_w, responsv_full)

## direct democracy
# select vars we need
tm <- tm_all %>% 
  select(dd, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, inst_trust) %>% 
  na.omit()

# model fit
modelfit_fun_glm("dd", dd_full)
quasi_mcfadden("dd", tm_w, dd_full)

## deliberative democracy
# select vars we need
tm <- tm_all %>% 
  select(delib, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, inst_trust) %>% 
  na.omit()

# model fit
modelfit_fun_glm("delib", delib_full)
quasi_mcfadden("delib", tm_w, delib_full)

## technocracy
# select vars we need
tm <- tm_all %>% 
  select(tech, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, inst_trust) %>% 
  na.omit()

# model fit
modelfit_fun_glm("tech", tech_full)
quasi_mcfadden("tech", tm_w, tech_full)

## free speech
# select vars we need
tm <- tm_all %>% 
  select(free_speech, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew, inst_trust) %>% 
  na.omit()

# model fit
modelfit_fun_glm("free_speech", free_full)
quasi_mcfadden("free_speech", tm_w, free_full)


tm <- tm_all # reset


```


## Model Support for Minority Rights

Now, we will examine the association between Covid-19 conspiracy beliefs and two additional elements of democracy: minority rights and horizontal accountability. While the first showed a positive bivariate association (see [Corrplot with all items from democracy battery](#corrplot-with-all-items-from-democracy-battery)), the latter did not.

We compute three model specifications to ensure our findings are robust: 

* a `glm` with socio-demographics only, 
* a full `glm` model (including the same predictors as in the main model), 
* and a `svyglm`model mirroring the main model.


```{r models minority rights}
# socio-demographics only
minority_sd <- glm(minority_rights~conspir_mean+age+sex+educ_gr,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# glm
minority_full <- glm(minority_rights~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# svyglm
minority_svy <- svyglm(minority_rights~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                        family = quasibinomial(link = "logit"),
                        design = tm_w)

```

```{r model summary minority rights, warning=F, message=F}
modelsummary(
  list("Model 1" = minority_sd,
       "Model 2" = minority_full,
       "Model 3 (svyglm)" = minority_svy),
  exponentiate = T, # get OR
  stars = T,
  output = "tinytable",
  statistic = "conf.int",
  gof_omit = "RMSE|R2|Deviance|F|AIC|BIC|Log.Lik",
  title = "Logistic Regression Models Minority Rights (Odds Ratios)",
  coef_rename = coef_names
)

```

#### What do the results tell us?

Whil significant in the socio-demographics only model, minority rights and CT belief are *not* significantly associated in the full model(s).


#### Model fit

```{r model fit minority rights}
# select vars to ensure null model and full model are computed on same data
tm <- tm_all %>% 
  select(minority_rights, conspir_mean, age, sex, educ_gr, persgew) %>% 
  na.omit()

modelfit_fun_glm("minority_rights", minority_sd)
quasi_mcfadden("minority_rights", tm_w, minority_sd)

# select vars 
tm <- tm_all %>% 
  select(minority_rights, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew) %>% 
  na.omit()

modelfit_fun_glm("minority_rights", minority_full)
quasi_mcfadden("minority_rights", tm_w, minority_full)

lrt_fun_svyglm("minority_rights", tm_w, minority_svy)
quasi_mcfadden("minority_rights", tm_w, minority_svy)


tm <- tm_all # reset
```


## Model horizontal accountability

Now, we turn to horizontal accountability that was measured with the item "...that government is controlled by a strong opposition", where respondents had to rate the importance of this element on a 4-point scale. Like in all other models, the item was recoded into a dummy variable, were 3 was the cut-off. 

```{r models horizontal accountability}
# socio-demographics only
opposition_sd <- glm(opposition~conspir_mean+age+sex+educ_gr,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# glm
opposition_full <- glm(opposition~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                     family = quasibinomial(link = "logit"),
                     weights = persgew,
                     data = tm)

# svyglm
opposition_svy <- svyglm(opposition~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                        family = quasibinomial(link = "logit"),
                        design = tm_w)
```

```{r model summary horizontal accountability, warning=F, message=F}
modelsummary(
  list("Model 1" = opposition_sd,
       "Model 2" = opposition_full,
       "Model 3 (svyglm)" = opposition_svy),
  exponentiate = T, # get OR
  stars = T,
  output = "tinytable",
  statistic = "conf.int",
  gof_omit = "RMSE|R2|Deviance|F|AIC|BIC|Log.Lik",
  title = "Logistic Regression Models Horizontal Accountability (Odds Ratios)",
  coef_rename = coef_names
)

```

#### What do the results tell us?

As already assumed based on the non-significant bivariate association, CT beliefs and horizontal accountability are not significantly associated in any of the model specifications. 

#### Model fit

```{r model fit horizontal accountability}
# select vars to ensure null model and full model are computed on same data
tm <- tm_all %>% 
  select(opposition, conspir_mean, age, sex, educ_gr, persgew) %>% 
  na.omit()

modelfit_fun_glm("opposition", opposition_sd)
quasi_mcfadden("opposition", tm_w, opposition_sd)

# select vars 
tm <- tm_all %>% 
  select(opposition, conspir_mean, age, sex, educ_gr, pol_inter, lr,extrem_sq, Autoritarismus, ext_effic, swd, persgew) %>% 
  na.omit()

modelfit_fun_glm("opposition", opposition_full)
quasi_mcfadden("opposition", tm_w, opposition_full)

lrt_fun_svyglm("opposition", tm_w, opposition_svy)
quasi_mcfadden("opposition", tm_w, opposition_svy)


tm <- tm_all # reset
```


## Models using svyglm

As discussed earlier, we opted for `glm()` in the main analysis because our survey design is simple (no clustering, no stratification). 

As a robustness check, we also estimated the models using `svyglm()`. This method is more appropriate for handling complex survey designs and provides robust standard errors. Hence, `svyglm()` provides a more conservative approach. 

Contrary to the main models using `glm()`, the association between Covid-19 conspiracy beliefs and support for **responsiveness** as well as **direct democracy** is relatively weak and the CT belief coefficient in both models is only significant at the **90% level**. While the negative association with **free and fair elections** becomes **insignificant**. The strong and positive association with support for technocracy persists, however. 

One important point to consider is the role of satisfaction with democracy (`swd`). **When we remove the `swd` variable from the models**, the CT belief coefficients in both the responsiveness and direct democracy models become **significant again** - only the insignificant coefficient in the elections model persists. 

This pattern suggests a potential **indirect effect**: Covid-19 conspiracy beliefs may lead to lower satisfaction with democracy, which in turn increases support for direct democracy  or the  delegate model of representation (Spearman's rho for the association is -0.38, p<0.001).  

Both models without the `swd` variable are not displayed here, but they can be found in the markdown script. To display them in the HTML output, set the `include=` argument in the header of the relevant chunk to `include=T`.

```{r svyglm}
# support for idea of democracy
dem_idea_svy <- svyglm(dem_idea~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                        family = quasibinomial(link = "logit"),
                        design = tm_w)

# support for dictatorship
dict_svy <- svyglm(dict~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                        family = quasibinomial(link = "logit"),
                        design = tm_w)

# elections
elect_svy <- svyglm(elect~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                     family = quasibinomial(link = "logit"),
                     design = tm_w) # n.s.

# responsiveness
responsv_svy <- svyglm(responsv~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                        family = quasibinomial(link = "logit"),
                        design = tm_w) # only at 90%

# direct democracy
dd_svy <- svyglm(dd~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                  family = quasibinomial(link = "logit"),
                  design = tm_w) # only at 90%

# deliberative democracy
delib_svy <- svyglm(delib~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                     family = quasibinomial(link = "logit"),
                     design = tm_w)

# technocracy
tech_svy <- svyglm(tech~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                    family = quasibinomial(link = "logit"),
                    design = tm_w)

# free speech
free_svy <- svyglm(free_speech~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                    family = quasibinomial(link = "logit"),
                    design = tm_w)
```

```{r model summary svyglm, warning=F, message=F}
modelsummary(
  list("Idea of democracy" = dem_idea_svy,
       "Dictatorship" = dict_svy,
       "Elections" = elect_svy,
       "Responsiveness" = responsv_svy,
       "Direct Dem." = dd_svy,
       "Delib. Dem." = delib_svy,
       "Technocracy" = tech_svy,
       "Free speech" = free_svy),
  exponentiate = T, # get OR
  stars = T,
  output = "tinytable",
  statistic = "conf.int",
  gof_omit = "RMSE|R2|Deviance|F|AIC|BIC|Log.Lik",
  title = "Logistic Regression Models Conceptions for Democracy with svyglm (Odds Ratios)",
  coef_rename = coef_names
)
```

#### Model Fit
```{r model fit svyglm}
lrt_fun_svyglm("dem_idea", tm_w, dem_idea_svy)
lrt_fun_svyglm("dict", tm_w, dict_svy)
lrt_fun_svyglm("elect", tm_w, elect_svy)
lrt_fun_svyglm("responsv", tm_w, responsv_svy)
lrt_fun_svyglm("dd", tm_w, dd_svy)
lrt_fun_svyglm("delib", tm_w, delib_svy)
lrt_fun_svyglm("free_speech", tm_w, free_svy) # n.s.
```


```{r svyglm reduced, include=F}
# support for idea of democracy
dem_idea_svy <- svyglm(dem_idea~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+lr+extrem_sq+Autoritarismus,
                        family = quasibinomial(link = "logit"),
                        design = tm_w)

# support for dictatorship
dict_svy <- svyglm(dict~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+lr+extrem_sq+Autoritarismus,
                        family = quasibinomial(link = "logit"),
                        design = tm_w)

# elections
elect_svy <- svyglm(elect~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+lr+extrem_sq+Autoritarismus,
                     family = quasibinomial(link = "logit"),
                     design = tm_w) # n.s.

# responsiveness
responsv_svy <- svyglm(responsv~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+lr+extrem_sq+Autoritarismus,
                        family = quasibinomial(link = "logit"),
                        design = tm_w) # only at 90%

# direct democracy
dd_svy <- svyglm(dd~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+lr+extrem_sq+Autoritarismus,
                  family = quasibinomial(link = "logit"),
                  design = tm_w) # only at 90%

# deliberative democracy
delib_svy <- svyglm(delib~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+lr+extrem_sq+Autoritarismus,
                     family = quasibinomial(link = "logit"),
                     design = tm_w)

# technocracy
tech_svy <- svyglm(tech~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+lr+extrem_sq+Autoritarismus,
                    family = quasibinomial(link = "logit"),
                    design = tm_w)

# free speech
free_svy <- svyglm(free_speech~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+lr+extrem_sq+Autoritarismus,
                    family = quasibinomial(link = "logit"),
                    design = tm_w)
```

```{r model summary svyglm reduced, warning=F, message=F, include=F}
modelsummary(
  list("Idea of democracy" = dem_idea_svy,
       "Dictatorship" = dict_svy,
       "Elections" = elect_svy,
       "Responsiveness" = responsv_svy,
       "Direct Dem." = dd_svy,
       "Delib. Dem." = delib_svy,
       "Technocracy" = tech_svy,
       "Free speech" = free_svy),
  exponentiate = T, # get OR
  stars = T,
  output = "tinytable",
  statistic = "conf.int",
  gof_omit = "RMSE|R2|Deviance|F|AIC|BIC|Log.Lik",
  title = "Logistic Regression Models Conceptions for Democracy with svyglm (Odds Ratios)",
  coef_rename = coef_names
)
```



## Ordinal Logistic Regression Models

We further conducted a robustness check using ordinal logistic regression; the results regarding conspiracy belief remain unchanged.

A more robust variant using `svyolr()` from the survey package can be found in the markdown script. Here, the CT belief coefficient for elections is *not* significant, while the one in the responsiveness model drops to the 90% level. To display the results of the `svyolr()` in the HTML output, set `include=T` in the relevant chunk.

```{r ordinal models polr from MASS, warning=F, message=F}
# support for idea of democracy
dem_idea_ordinal <- polr(dem_idea4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                         method = "logistic",
                         Hess=T,
                         weights = persgew,
                         data = tm)

# support for dictatorship
dict_ordinal <- polr(dict4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                     method = "logistic",
                     Hess=T,
                     weights = persgew,
                     data = tm)

# elections
elect_ordinal <- polr(elect4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                      method = "logistic",
                      Hess=T,
                      weights = persgew,
                      data = tm)

# responsiveness
responsv_ordinal <- polr(responsv4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                         method = "logistic",
                         Hess=T,
                         weights = persgew,
                         data = tm)

# direct democracy
dd_ordinal <- polr(dd4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                   method = "logistic",
                   Hess=T,
                   weights = persgew,
                   data = tm)

# deliberative democracy
delib_ordinal <- polr(delib4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                      method = "logistic",
                      Hess=T,
                      weights = persgew,
                      data = tm)

# technocracy
tech_ordinal <- polr(tech4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                     method = "logistic",
                     Hess=T,
                     weights = persgew,
                     data = tm)

# free speech
free_ordinal <- polr(free_speech4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                     method = "logistic",
                     Hess=T,
                     weights = persgew,
                     data = tm)

```

```{r model summary ordinal logistic regression polr, warning=F, message=F}
modelsummary(
  list("Idea of democracy" = dem_idea_ordinal,
       "Dictatorship" = dict_ordinal,
       "Elections" = elect_ordinal,
       "Responsiveness" = responsv_ordinal,
       "Direct Dem." = dd_ordinal,
       "Delib. Dem." = delib_ordinal,
       "Technocracy" = tech_ordinal,
       "Free speech" = free_ordinal),
  exponentiate = T, # get OR
  stars = T,
  output = "tinytable",
  statistic = "conf.int",
  gof_omit = "RMSE|R2|Deviance|F|AIC|BIC|Log.Lik",
  title = "Ordinal Logistic Regression Models (Odds Ratios)",
  fmt = 2,
  coef_rename = coef_names
)
```

We tested the parallel odds assumption using Brant tests (Brant 1990). The results indicate that while the assumption of parallel odds holds for our main independent variable (conspiracy belief) across all models, it was violated for the overall model in most cases (specifically in models idea of democracy, dictatorship, direct democracy, technocracy, and deliberative democracy). Hence, the effects of some predictors on the ordered outcomes vary across the different thresholds and may affect the interpretation of how these predictors influence the DV across its different levels. To view the results of the brant test in the HTML output, set `include=T` in the relevant chunk.

```{r brant test for parallel odds assumption, include=F}

brant(dem_idea_ordinal) %>% 
  kbl(digits = 2,
      caption = "Parallel Odds Assumption Support for Democracy") %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed")) # violated, but holds for CB

brant(dict_ordinal) %>% 
  kbl(digits = 2,
      caption = "Parallel Odds Assumption Support for Dictatorship") %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed")) # violated, but holds for CB

brant(elect_ordinal) %>% 
  kbl(digits = 2,
      caption = "Parallel Odds Assumption Importance of Elections") %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed")) # ok, and holds for CB

brant(responsv_ordinal) %>% 
  kbl(digits = 2,
      caption = "Parallel Odds Assumption Responsiveness") %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed")) # ok, and holds for CB

brant(dd_ordinal) %>% 
  kbl(digits = 2,
      caption = "Parallel Odds Assumption Direct Democracy") %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed")) # violated, but holds for CB

brant(delib_ordinal)  %>% 
  kbl(digits = 2,
      caption = "Parallel Odds Assumption Deliberative Democracy") %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed")) # violated, but holds for CB

brant(tech_ordinal)  %>% 
  kbl(digits = 2,
      caption = "Parallel Odds Assumption Technocracy") %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed")) # violated, but holds for CB

brant(free_ordinal) %>% 
  kbl(digits = 2,
      caption = "Parallel Odds Assumption Importance of Free Speech") %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed")) # ok, and holds for CB


```

```{r ordinal models with svyolr, include=F}
dem_idea_ordinal <- svyolr(dem_idea4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                           design = tm_w)
dict_ordinal <- svyolr(dict4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                       design = tm_w)
elect_ordinal <- svyolr(elect4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                        design = tm_w)
responsv_ordinal <- svyolr(responsv4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                           design = tm_w)
dd_ordinal <- svyolr(dd4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                     design = tm_w)
delib_ordinal <- svyolr(delib4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                        design = tm_w)
tech_ordinal <- svyolr(tech4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                       design = tm_w)
free_ordinal <- svyolr(free_speech4~conspir_mean+age+sex+educ_gr+pol_inter+ext_effic+swd+lr+extrem_sq+Autoritarismus,
                       design = tm_w)
```

```{r model summary svyolr, warning=F, message=F, include=F}
modelsummary(
  list("Idea of democracy" = dem_idea_ordinal,
       "Dictatorship" = dict_ordinal,
       "Elections" = elect_ordinal,
       "Responsiveness" = responsv_ordinal,
       "Direct Dem." = dd_ordinal,
       "Delib. Dem." = delib_ordinal,
       "Technocracy" = tech_ordinal,
       "Free speech" = free_ordinal),
  exponentiate = T, # get OR
  stars = T,
  output = "tinytable",
  statistic = "conf.int",
  gof_omit = "RMSE|R2|Deviance|F|AIC|BIC|Log.Lik",
  title = "Ordinal Logistic Regression Models Using svyolr (Odds Ratios)",
  fmt = 2,
  coef_rename = coef_names
)
```



## Corrplot with all items from democracy battery

Let's look at the corrplot from above, but this time with all items from the democracy battery. We see that there are no other items that are significantly associated with the conspiracy belief mean scale. The item `V08MI` displays a negative and significant association, but we explored that in the Appendix already. 

```{r corrplot all demo vars, fig.width=16.5, fig.height=16.5}
# DVs
demo_all <- c("conspir_mean", "V08", "V12D", "V701A", "V12EX", "V08PG", "V08SG", "V08CG", "V08MF", "V08W", "V08OP", "V08MI", "V08RS1", "V08RS2", "V08RS3", "V08EZ", "V08DR", "V08DD", "V08AC")

# function, computing weigthed corr coefficient with indep_test
# that's the only way we get coeffs AND p-values!
weighted_corr <- function(var1, var2, data, weights) {
  indep_test(
    x = data[[var1]], 
    y = data[[var2]], 
    weights = data[[weights]], 
    method = "spearman"
  )
}

# df to store results of loop
results <- data.frame(V1 = character(), V2 = character(), coeff = numeric(), p = numeric())

# loop
for (i in 1:(length(demo_all) - 1)) {
  for (j in (i + 1):length(demo_all)) {
    # varnames
    var1 <- demo_all[i]
    var2 <- demo_all[j]

    # run weigthed corrs function
    test <- weighted_corr(var1, var2, data = tm, weights = "persgew") 
    
    # store coeff and p-value
    rho <- test$estimate
    p_value <- test$p_value

    # append loop output to results df
    results <- rbind(results, data.frame(V1 = var1, V2 = var2,
                                         coeff = rho,
                                         p = p_value))
  }
}

# results # check

# now, we need to get the "results" df into wide format / or actually a materix to apply it to corrplot

# diagonal correlations are set to 1 (self-correlation)
diag_entries <- data.frame(
  V1 = unique(c(results$V1, results$V2)),
  V2 = unique(c(results$V1, results$V2)),
  coeff = 1,
  p = NA
)

# join self-correlations df with actual results df
results_full <- bind_rows(results, diag_entries) %>%
  # all pairwise correlations are present in both directions
  bind_rows(results %>% rename(V1 = V2, V2 = V1))

results_full <- results_full %>%
  distinct(V1, V2, .keep_all = T)

# wide format for corr matrix style
corr_matrix <- results_full %>%
  select(V1, V2, coeff) %>%
  pivot_wider(names_from = V2, values_from = coeff)

# corr_matrix  check

# set 1st column as rownames and then remove it from df
corr_matrix <- as.data.frame(corr_matrix)
rownames(corr_matrix) <- corr_matrix$V1
corr_matrix <- corr_matrix %>% 
  select(-V1)

# change order (conspir_mean first), so diagonal in corrplot is applied correctly
corr_matrix <- corr_matrix %>% 
  select(conspir_mean, V08, V12D, V701A, V12EX, V08PG, V08SG, V08CG, V08MF, V08W, V08OP, V08MI, V08RS1, V08RS2, V08RS3, V08EZ, V08DR, V08DD, V08AC)

# covert df to matrix to use it in corrplot
corr_matrix <- as.matrix(corr_matrix)

# same with p
p_matrix <- results_full %>%
  select(V1, V2, p) %>%
  pivot_wider(names_from = V2, values_from = p)

# set 1st column as rownames and then remove it from df
p_matrix <- as.data.frame(p_matrix)
rownames(p_matrix) <- p_matrix$V1
p_matrix <- p_matrix %>% 
  select(-V1)

# change order (conspir_mean first), so diagonal in corrplot is applied correctly
p_matrix <- p_matrix %>% 
  select(conspir_mean, V08, V12D, V701A, V12EX, V08PG, V08SG, V08CG, V08MF, V08W, V08OP, V08MI, V08RS1, V08RS2, V08RS3, V08EZ, V08DR, V08DD, V08AC)

# covert df to matrix to use it in corrplot
p_matrix <- as.matrix(p_matrix)


# the plot
corrplot(corr_matrix,
         p.mat = p_matrix, # get manual pvalues data
         method = "circle",
         type = "upper",
         insig ="pch", # cross out insignif. values
         diag = F,
         tl.col = "black",
         tl.srt = 45, # aligns top labels 45 degrees
         addCoef.col = "white", # add corr coeff values inside circles
         is.corr = F)

```



# Summary Statistics of All Variables

```{r}

##### functions #####
# function: summary stats for metric vars
my_descriptives <- function(var_name, design_name) {
  list(
    mean = round(svymean(~var_name, design_name, na.rm=T),3),
    quantiles = svyquantile(~var_name, design_name, c(0.25, 0.5, 0.75), na.rm=T),
    sd = round(sqrt(svyvar(~var_name, design_name , na.rm=T)),3)
  )
}

# input in my_descriptives: df_w$variables$var_name

# function: summary stats for categorical/dummy
descriptives_table <- function(var_name, design_name) {
  var_name_new <- as.formula(paste0("~", var_name))
  t <- svytable(var_name_new , design_name)
  list(absolute = round(t,0),
       percent = round(prop.table(t)*100,1)
  )
}

# input in descriptives_table: "var_name"


##### NAs #####
# check NA for all vars
## select var we need
df <- tm %>% 
  select(dem_idea, dict, elect, responsv, free_speech, dd, tech, delib, opposition, minority_rights, 
         conspir_mean,
         age, sex, educ_gr, pol_inter,
         lr, extrem, extrem_sq, Autoritarismus,
         party_id, govt_opp, 
         ext_effic, swd, inst_trust
         ) 


colSums(is.na(df))


##### Summary statistics #####

## Metric
my_descriptives(tm_w$variables$conspir_mean, tm_w) # Conspiracy mean scale
my_descriptives(tm_w$variables$age, tm_w) # age
my_descriptives(tm_w$variables$pol_inter, tm_w) # political interest
my_descriptives(tm_w$variables$lr, tm_w) # left-right self-placement
my_descriptives(tm_w$variables$extrem, tm_w) # extremism
my_descriptives(tm_w$variables$extrem_sq, tm_w) # extremism squared
my_descriptives(tm_w$variables$inst_trust, tm_w) # political trust

## Categorical
# support for idea of democracy
descriptives_table("dem_idea", tm_w)
# support for dictatorship
descriptives_table("dict", tm_w)
# importance of elections
descriptives_table("elect", tm_w)
# responsiveness
descriptives_table("responsv", tm_w)
# importance of free speech
descriptives_table("free_speech", tm_w)
# support for direct democracy
descriptives_table("dd", tm_w)
# support for technocracy
descriptives_table("tech", tm_w)
# deliberative democracy
descriptives_table("delib", tm_w)
# importance of horizontal accountability
descriptives_table("opposition", tm_w)
# importance of miniroty rights
descriptives_table("minority_rights", tm_w)
# gender
descriptives_table("sex", tm_w)
# education
descriptives_table("educ_gr", tm_w)
# party ID
descriptives_table("party_id", tm_w)
# party ID (supporter of govt. vs. opposition party vs. no party ID)
descriptives_table("govt_opp", tm_w)
# external efficacy
descriptives_table("ext_effic", tm_w)
# satisfaction with democracy
descriptives_table("swd", tm_w)


```



